﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Edit.aspx.cs" Inherits="Web.Admin.Page_Administrator.Edit" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>

<!DOCTYPE html>

<%="<!--[if IE 8]> <html class=\"ie8 no-js\"> <![endif]-->"%>
<%="<!--[if IE 9]> <html class=\"ie9 no-js\"> <![endif]-->"%>
<%="<!--[if !IE]><!-->"%>
<html>
<%="<!--<![endif]-->"%>
    <!-- BEGIN HEAD -->

    <head>
        <meta charset="utf-8" />
        <title><%=Evan.Common.CommFun.GetAppSetting("AdminTitle") %> - 后台管理系统</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta content="width=device-width, initial-scale=1" name="viewport" />
        <!-- #include file="../include/com_res_css.inc" -->
    </head>
    <!-- END HEAD -->

    <body class="page-header-fixed page-sidebar-closed-hide-logo page-content-white">
        <!-- BEGIN HEADER -->
        
        <!-- #include file="../include/top_bar.inc" -->

        <!-- END HEADER -->
        <!-- BEGIN HEADER & CONTENT DIVIDER -->
        <div class="clearfix"> </div>
        <!-- END HEADER & CONTENT DIVIDER -->
        <!-- BEGIN CONTAINER -->
        <div class="page-container">
            <!-- BEGIN SIDEBAR -->
            
            <!-- #include file="../include/left_menu.inc" -->
            
            <!-- END SIDEBAR -->
            <!-- BEGIN CONTENT -->
            <div class="page-content-wrapper">
                <!-- BEGIN CONTENT BODY -->
                <div class="page-content">
                    <!-- BEGIN PAGE HEADER-->
                    <!-- BEGIN THEME PANEL -->
                    <!-- #include file="../include/theme_panel.inc" -->
                    <h3 class="page-title"> 管理员管理</h3>
                    <!-- END PAGE TITLE-->
                    <!-- END PAGE HEADER-->
                    <!-- BEGIN PAGE CONTENT-->

                                    <div class="portlet light bordered">
                                        <div class="portlet-title tabbable-line">

                                            <div class="caption">
                                                <i class="glyphicon glyphicon-list-alt font-red"></i>
                                                <span class="caption-subject font-red bold uppercase">管理员管理</span>
                                            </div>

                                        </div>
                                        <div class="tab-content">

                                            <div class="tab-pane active" id="tab_1">
                                                <div class="form">
                                                    <div class="form-horizontal form-row-seperated">
                                                        <div class="form-body">
                                                            
                                                            <%
                                                                List<dynamic> RoleList = new Evan.DataBase.DbOperat("Roles").GetList_2(0,"Id,Title","States=1","Id Desc");
                                                                Dictionary<string, string> Dic_Role_List = new Dictionary<string, string>();
                                                                foreach (var item in RoleList)
                                                                {
                                                                    Dic_Role_List.Add(item.Id.ToString(), item.Title.ToString());
                                                                }

                                                                Evan.Model.SysModel.HtmlHelperModel f1 = new Evan.Model.SysModel.HtmlHelperModel { Title = "管理账户", PlaceHoder = "请输入管理账户", Notice = "管理账户名 20字符以内 , 可使用字母、数字 , <b class='font-red'>禁止使用中文、空格</b> , 用于系统登录", FieldName = "Name", FieldVerify = "notnull", MaxLength = 20, FieldType = "input" };
                                                                Evan.Model.SysModel.HtmlHelperModel f2 = new Evan.Model.SysModel.HtmlHelperModel { Title = "管理密码", PlaceHoder = "请输入管理密码", Notice = "管理员密码 , 字母数字组合 , <b class='font-red'>禁止使用中文、空格</b>", FieldName = "Pwd", FieldVerify = "notnull", MaxLength = 50, FieldType = "password_eye" };
                                                                Evan.Model.SysModel.HtmlHelperModel f3 = new Evan.Model.SysModel.HtmlHelperModel { Title = "姓名", PlaceHoder = "请输入管理员的姓名", Notice = "管理员真实姓名 20字内", FieldName = "RealName", FieldVerify = "", MaxLength = 20, FieldType = "input" };
                                                                Evan.Model.SysModel.HtmlHelperModel f4 = new Evan.Model.SysModel.HtmlHelperModel { Title = "微信", PlaceHoder = "管理员微信号", Notice = "管理员微信号", FieldName = "WeChat", FieldVerify = "", MaxLength = 50, FieldType = "input" };
                                                                Evan.Model.SysModel.HtmlHelperModel f5 = new Evan.Model.SysModel.HtmlHelperModel { Title = "角色", PlaceHoder = "请选择角色", Notice = "选择管理角色", FieldName = "RoleId", FieldVerify = "notnull", MaxLength = 20, FieldType = "select", SelectItem = Dic_Role_List };
                                                                Evan.Model.SysModel.HtmlHelperModel f6 = new Evan.Model.SysModel.HtmlHelperModel { Title = "电话", PlaceHoder = "输入管理员的电话号码", Notice = "输入管理员的电话号码", FieldName = "Tel", FieldVerify = "", MaxLength = 20, FieldType = "input" };
                                                                Evan.Model.SysModel.HtmlHelperModel f7 = new Evan.Model.SysModel.HtmlHelperModel { Title = "锁定", PlaceHoder = "锁定", Notice = "锁定后将不能登录", FieldName = "States", FieldVerify = "", MaxLength = 20, FieldType = "switch" };
                                                                List<Evan.Model.SysModel.HtmlHelperModel> html = new List<Evan.Model.SysModel.HtmlHelperModel>();
                                                                html.Add(f1);
                                                                html.Add(f2);
                                                                html.Add(f3);
                                                                html.Add(f4);
                                                                html.Add(f5);
                                                                html.Add(f6);
                                                                html.Add(f7);
                                                                foreach (Evan.Model.SysModel.HtmlHelperModel item in html)
                                                                {
                                                                    Response.Write(Evan.Common.HtmlHelper.HtmlBuild(item));
                                                                }
                                                            %>
                                                                
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-actions form-submit-row">
                                            <div class="form-group">
                                                <label class="control-label col-md-2"></label>
                                                <div class="col-md-6">
                                                    <button type="button" class="btn btn-primary submit_administrator"><i class="fa fa-check"></i> 提交</button>
                                                </div>
                                            </div>  
                                            <div class="clear"></div>
                                        </div>

                                    </div>

                    
                    <!-- END PAGE CONTENT-->
                </div>
                <!-- END CONTENT BODY -->
            </div>
            <!-- END CONTENT -->
            
        </div>
        <!-- END CONTAINER -->
        <!-- #include file="../include/footer.inc" -->
   <!-- #include file="../include/com_res_js.inc" -->
    </body>
    
     <script  type="text/javascript">
         $(".submit_administrator").on("click", function () {
             var _this = this;
             model = MakeModel();
             model["Pwd"] = rsa.Encrypt(StrDeCode(model["Pwd"]));
             if (model.RoleId==0) {
                 alert("请选择当前管理员所属角色");
                 return false;
             }
             var data = { model: JSON.stringify(model), table: QueryString.GetValue("t") };

             var ActionType = "操作";
             if (IsAddAction()) {
                 ActionType = "添加";
             }
             if (IsEditAction()) {
                 ActionType = "编辑";
             }

             $(_this).button('loading');
             AjaxSubmit(appConfig.adminPath+"ashx/administrator.ashx",QueryString.GetValue("action"), data, function (f, d) {
                 $(_this).button('reset');
                 if (f) {
                     //请求成功
                     if (parseInt(d.result)>0) {
                         alert(ActionType+"成功",function(){
                             setTimeout(function(){
                                 JumpList();
                             },500);
                         });
                     }
                     else if (parseInt(d.result)==-10) {
                         alert(ActionType+"失败 , 管理账户已存在 , 请勿重复设置 !");
                     }
                     else{
                         alert(ActionType+"失败 , 请稍后重试 !");
                     }
                 }
                 else{
                     //请求失败
                     alert("请求出错 , 请稍后刷新重试 !");
                 }
             });
         });
         
         var model = <%=Evan.Model.ConvertModel.ConvertToJson(Model)%>;
         <%if (Model!=null){%>
            model["Pwd"] = '<%=Evan.Common.CommFun.RePwd(Model.Pwd)%>';
         <%}%>
         SetModel(model);
         
  </script>
</html>


